<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jQuery跨域</title>
    <style>
        input{width:600px;height:30px;border:1px solid blue;margin-top:100px;margin-left:300px;}
        li{list-style:none;background:lightgoldenrodyellow ;width:600px;height:30px;display:none;}
        ul{margin-left:260px;}
        .aa{display:block;}
    </style>
</head>
<body>
<input type="text">
<ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>
</body>
</html>
<script src="jquery.js "></script>
<script>
    $(function(){
        $("input").keyup(function(){
            $.ajax({
                type:"get",
                data:"wd="+$(this).val(),
                dataType:"jsonP",
                url:"http://suggestion.baidu.com/su",
                success:function(data){
                }
            });
        });
    });
    var baidu={
        sug:function(data){
            for(var i=0;i<10;i++){
                document.getElementsByTagName ("li")[i].setAttribute("class","aa");
                document.getElementsByTagName ("li")[i].innerText =data.s[i];
                if($("input").val().length>8||$("input").val().length==0){
                    $("li").removeAttr("class")
                }
            }

        }
    }

</script>
